package com.guigu.serviceorder.controller;

import com.guigu.common_util.pojo.utils.Result;
import com.guigu.serviceorder.entity.CategoryReport;
import com.guigu.serviceorder.service.CategoryReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/categoryReport")
public class CategoryReportController {

    @Autowired
    private CategoryReportService categoryReportService;

    /**
     * 昨天的数据统计（商品类目）
     * @return
     */
    @GetMapping("/yesterday")
    public List<CategoryReport> yesterday(){
        LocalDate localDate=LocalDate.now().minusDays(1);// 得到昨天日期
        return categoryReportService.categoryReport(localDate);
    }

    @GetMapping("/category1Count")
    public Result category1Count(String date1,String date2){
        List<Map> maps = categoryReportService.category1Count(date1, date2);
       return Result.ok().data("rows",maps);
    }

    @GetMapping("/mentnum")
    public Result mentnum(String date1,String date2){
        List<Map> namenum = categoryReportService.namenum(date1, date2);
        return Result.ok().data("rows",namenum);
    }

    @GetMapping("/ordersourcenum")
    public Result ordersourcenum(String date1){
        List<Map> ordersourcenum = categoryReportService.ordersourcenum(date1);
        return Result.ok().data("rows",ordersourcenum);
    }


}
